/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.scm.rmpm.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author Kenn
 */
@Entity
public class RawMaterialInventoryRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private Double balance;
    private Double optimalStock;
    @OneToOne(targetEntity = RawMaterial.class,cascade={CascadeType.PERSIST,CascadeType.MERGE}, fetch=FetchType.EAGER)
    private RawMaterial rawMaterial;
    @OneToMany(targetEntity = RawMaterialInventoryBatch.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private List<RawMaterialInventoryBatch> batches;
    
    public RawMaterialInventoryRecord(){
        balance = 0D;
        optimalStock =200D;
        rawMaterial = null;
        batches = new ArrayList<RawMaterialInventoryBatch>();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }

    public List<RawMaterialInventoryBatch> getBatches() {
        return batches;
    }

    public void setBatches(List<RawMaterialInventoryBatch> batches) {
        this.batches = batches;
    }

    public Double getOptimalStock() {
        return optimalStock;
    }

    public void setOptimalStock(Double optimalStock) {
        this.optimalStock = optimalStock;
    }

    public RawMaterial getRawMaterial() {
        return rawMaterial;
    }

    public void setRawMaterial(RawMaterial rawMaterial) {
        this.rawMaterial = rawMaterial;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof RawMaterialInventoryRecord)) {
            return false;
        }
        RawMaterialInventoryRecord other = (RawMaterialInventoryRecord) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "merlion.scm.rmpm.entity.RawMaterialInventoryRecord[ id=" + id + " ]";
    }
    
}
